var gl_vue_vm_list_html = $('#vue_vm_list').html();

$(function() {
    $('#vue_vm_list').hide();
});

var day = "";
var data = null;

function findRechargeRecordByDay() {
    if($('#vue_vm_list').length==0) {return;}
    $('#vue_vm_list').hide();
    var year = $('#year').val();
    var month = $('#month').val();
    var day = $('#day').val();
    var searchVal = $('#searchVal').val();

    if(isEmpty(year)) {
        alert('请输入年');
        return;
    }
    if(isEmpty(month)) {
        alert('请选择月');
        return;
    }
    if(isEmpty(day)) {
        alert('请选择日');
        return;
    }
    if(isEmpty(searchVal)) {
        alert('请输入姓名或身份证');
        return;
    }
    day = getStandardDay(year, month, day);
    find_basic_by_json(path+'/elderWallet/findRechargeRecordByDay', {day: day, searchVal: searchVal}, function(response) {
        $('#vue_vm_list').html(gl_vue_vm_list_html);

        new Vue({
            el: '#vue_vm_list',
            data: {
                todos: response.data
            },
            methods: {
                onRadioClick(todo){
                    data = todo;
                }
            }
        });

        $('#vue_vm_list').show();
    });
}

function printBuda() {
    if(!data){
        return;
    }
    var elderWalletRechargeRecordId = data.elderWalletRechargeRecordId;
    var paperRecordForm = data.paperRecordForm;
    var elderBeHospitalForm = data.elderBeHospitalForm;
    var elderName = data.elderForm.name;

    var pageParam = {};
    pageParam.elderId = elderBeHospitalForm.elderId;
    pageParam.elderName = elderName
    pageParam.payType = '预缴款';
    pageParam.pay = paperRecordForm.amount;
    pageParam.staffName = getLoginedUser()? getLoginedUser().staffName: '';
    pageParam.payDate = day;
    pageParam.paperType = 2;
    pageParam.beHospitalId =elderBeHospitalForm.beHospitalId;
    pageParam.beNumber = elderBeHospitalForm.beNumber;
    pageParam.relationId = elderWalletRechargeRecordId + '-walletRecharge';
    window.open('0_print_jf.html?pageParam='+encodeURIComponent(JSON.stringify(pageParam)));
}
